package com.example.libraryapp.activity.login;

import com.example.libraryapp.bean.User;
import com.example.libraryapp.bean.response.BaseResponse;
import com.example.libraryapp.network.base.BaseHttpHandler;
import com.example.libraryapp.network.base.BasePresenter;

/**
 * @author 伍凯铭
 * @since 2020/6/19
 */
public class LoginPresenterIml extends BasePresenter<LoginContract.View> implements LoginContract.Presenter{

    @Override
    public void doLogin(String sno, String password) {
        super.doRequest(getRequestService().login(sno,password),new LoginHandler());
    }

    class LoginHandler extends BaseHttpHandler<BaseResponse<User>> {

        LoginHandler() {
            super(mView);
        }

        @Override
        public void onSuccess(BaseResponse<User> response) {
            if(mView != null) {
                mView.showContent();
                mView.showLogin(response);
            }
        }
    }
}
